//
//  SWOrderCreateReq.swift
//  ChildStory
//
//  Created by linhan on 2017/1/19.
//  Copyright © 2017年 Aiya. All rights reserved.
//

import Foundation
class SWOrderCreateReq: SWBaseRequest
{
    var addressID:Int = 0
    
    //订单备注
    var remark:String = ""
    
    var count:Int = 1
    
    override init()
    {
        super.init()
        api = SWRequestAPI.AddressCreate
    }
    
    override var url:String
    {
        return "http://mpic.bbyiya.com/order/submitOrder"
    }
    
    override var params:Any?
    {
        var data:[String:Any] = [:]
        data["productId"] = 1001
        data["styleId"] = 1001
        data["count"] = count
        
        
        let jsonString:String = JSONHelper.JSONEncode(data)
        trace("SWOrderCreateReq", jsonString)
        
        return ["productJsonStr":jsonString, "addrId":addressID, "remark":remark]
    }
    
    override func JSONToModel(_ json:JSON, JSONString:String, JSONData:Data) -> AnyObject?
    {
        trace(json)
        return Mapper<SWOrderCreateRsp>().map(JSONString: JSONString)
    }
}

class SWOrderCreateRsp: NSObject,Mappable
{
    var statu:String?
    var requisition:SWPurchaseRequisitionRsp?
    
    
    required init?(map: Map) { }
    
    // Mappable
    func mapping(map: Map) {
        statu                   <- map["Statu"]
        requisition             <- map["BaseModle"]
    }
}
